package action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import pageModel.Json;
import pageModel.Payment;
import service.PaymentServiceI;

import com.opensymphony.xwork2.ModelDriven;
@Namespace("/")
@Action(value="paymentAction")
public class PaymentAction extends BaseAction implements ModelDriven<Payment>{
Payment payment =new Payment();
private PaymentServiceI paymentService;

	public PaymentServiceI getPaymentService() {
	return paymentService;
}
@Autowired
public void setPaymentService(PaymentServiceI paymentService) {
	this.paymentService = paymentService;
}

	@Override
	public Payment getModel() {
		// TODO Auto-generated method stub
		return payment;
	}
public void save(){
	Json j=new Json();
	paymentService.save(payment.getTid(),payment.getPid(),payment.getVip(),payment.getMethod(),payment.getTotalprice(),payment.getCollection(),payment.getChanges());
	j.setSuccess(true);
	super.writeJson(j);
}
public void datagrid(){
	super.writeJson(paymentService.datagrid(payment.getCashier(),payment));
}
}
